package com.example.summary.sort;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wzn on 2019/1/10.
 */
public class FeiBoNaQie {

    static final Map<Integer, Integer> map = new HashMap<>();

    public static int Recursion(int n) {
        Integer integer = map.get(n);

        if (null != integer) {
            return integer;
        }

        if (n == 1) {
            return 1;
        }

        if (n == 2) {
            return 2;
        }

        integer = Recursion(n - 1) + Recursion(n - 2);
        map.put(n, integer);
        return integer;
    }

    public static void main(String[] args) {
        System.out.println(Recursion(3));
    }
}
